﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AliyunOpenSearch4Net.Base;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AliyunOpenSearch4Net.Test
{
    class TestConst
    {
        static TestConst()
        {
            AccessKeyID = ConfigurationManager.AppSettings["AccessKeyID"];
            AccessKeySecret = ConfigurationManager.AppSettings["AccessKeySecret"];

            // initialize test application
            var client = new AliyunClient(AccessKeyID, AccessKeySecret);

            var response = client.GetAppStatus(DefaultAppName);

            // not found
            if (response.Status == ApiStatus.FAIL && response.Errors[0].Code == 2001)
            {
                var createRespnse = client.CreateApp(DefaultAppName, TestConst.DefaultTemplateName);

                Assert.AreEqual(ApiStatus.OK, createRespnse.Status);
                Assert.AreEqual(DefaultAppName, createRespnse.Result.IndexName);
            }            
        }

        public static readonly string AccessKeyID;

        public static readonly string AccessKeySecret;

        public const string DefaultAppName = "MyTest";

        public const string DefaultTableName = "main";

        public const string DefaultTemplateName = "builtin_bbs";
    }
}
